import sevoes from "@/util/Http";
import Qs from "qs";
function listInquire(data) {//查询
  return sevoes({
    method: "get",
    params: {
      _gp: "admin.goods",
      _mt: "list",
      ...data
    }
  });
}

function getSpuBigTree() {//获取SPU树
  return sevoes({
    method: "get",
    params: {
      _gp: "admin.goods",
      _mt: "getSpuBigTree",
    }
  });
}

function create(data) {
  //添加
  return sevoes({
    method: "post",
    data: Qs.stringify({
      _gp: "admin.goods",
      _mt: "create",
      ...data,
    }),
  })
}

function edit(data) {
  //修改
  return sevoes({
    method: "post",
    data: Qs.stringify({
      _gp: "admin.goods",
      _mt: "edit",
      ...data,
    }),
  })
}

function freightInquire() {//查询运费
  return sevoes({
    method: "get",
    params: {
      _gp: "admin.freight",
      _mt: "getAllFreightTemplate"
    }
  });
}

function sdelete(data) {
  //删除
  return sevoes({
    method: "post",
    data: Qs.stringify({
      _gp: "admin.goods",
      _mt: "delete",
      ...data,
    }),
  })
}

function details(data) {//详情
  return sevoes({
    method: "get",
    params: {
      _gp: "admin.goods",
      _mt: "detail",
      ...data
    }
  });
}

//批量删除的接口
function batchDelete(id) {
    return sevoes({
      method: "post",
      data: Qs.stringify({
        _gp: "admin.goods",
        _mt: "batchDelete",
        ids: JSON.stringify([...id])
      })
    });
}

function freezeOrActivation(data) {//上架下架状态
  return sevoes({
    method: "post",
    data: Qs.stringify({
      _gp: "admin.goods",
      _mt: "freezeOrActivation",
      ...data
    })
  });
}

export default {listInquire,getSpuBigTree,create,edit,sdelete,details,batchDelete,freightInquire,freezeOrActivation}